package com.zhengshang.web.controller.app;

import com.zhengshang.api.domain.AppTaoOrder;
import com.zhengshang.api.service.IAppTaoOrderService;
import com.zhengshang.common.annotation.Log;
import com.zhengshang.common.core.controller.BaseController;
import com.zhengshang.common.core.domain.AjaxResult;
import com.zhengshang.common.core.page.TableDataInfo;
import com.zhengshang.common.enums.BusinessType;
import com.zhengshang.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 【请填写功能名称】Controller
 * 
 * @author zhengshang
 * @date 2022-04-27
 */
@RestController
@RequestMapping("/app/order")
public class AppTaoOrderController extends BaseController
{
    @Autowired
    private IAppTaoOrderService appTaoOrderService;

    /**
     * 查询【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('app:order:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppTaoOrder appTaoOrder)
    {
        startPage();
        List<AppTaoOrder> list = appTaoOrderService.selectAppTaoOrderList(appTaoOrder);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('app:order:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AppTaoOrder appTaoOrder)
    {
        List<AppTaoOrder> list = appTaoOrderService.selectAppTaoOrderList(appTaoOrder);
        ExcelUtil<AppTaoOrder> util = new ExcelUtil<AppTaoOrder>(AppTaoOrder.class);
        return util.exportExcel(list, "order");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize("@ss.hasPermi('app:order:query')")
    @GetMapping(value = "/{taoId}")
    public AjaxResult getInfo(@PathVariable("taoId") Long taoId)
    {
        return AjaxResult.success(appTaoOrderService.selectAppTaoOrderById(taoId));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('app:order:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppTaoOrder appTaoOrder)
    {
        return toAjax(appTaoOrderService.insertAppTaoOrder(appTaoOrder));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('app:order:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppTaoOrder appTaoOrder)
    {
        return toAjax(appTaoOrderService.updateAppTaoOrder(appTaoOrder));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('app:order:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{taoIds}")
    public AjaxResult remove(@PathVariable Long[] taoIds)
    {
        return toAjax(appTaoOrderService.deleteAppTaoOrderByIds(taoIds));
    }
}
